package com.example.yxweather.ui.home


import com.example.yxweather.base.BasePresenter
import com.qweather.sdk.response.weather.WeatherNowResponse

class HomePresenter(val mView: HomeView, val mInteractor: HomeInteractor) :
    BasePresenter<HomeView, HomeInteractor>(mView, mInteractor),
    HomeInteractor.GetWeatherData {

    private var currShowCityName = ""
    private var currShowLatitude = ""
    private var currShowLongitude = ""

    /**
     *  设置当前展示的城市名和经纬度数据
     */
    fun setCityLocationParams(cityName: String, latitude: String, longitude: String) {
        currShowCityName = cityName
        currShowLatitude = latitude
        currShowLongitude = longitude
    }


    override fun getWeatherDataSuccess(response: WeatherNowResponse) {
        mView.getMainWeatherDataSuccess(response)
    }

    override fun getWeatherDataFailed(msg: String) {
        mView.getMainWeatherDataFailed(msg)
    }

    fun requestMainWeatherData() {
        mInteractor.getCityCurrentWeather(currShowLatitude, currShowLongitude, this)
    }

}